package com.mud.dnd.domain.common;

public class QueryParameter {

	
	public enum QueryParamOperator
	{
		MORE(">="),
		LESS("<="),
		EQUALS("="),
		LIKE("LIKE");
		
		private String operatorString;
		
		private QueryParamOperator(String operatorStr)
		{
			operatorString = operatorStr;
		}
		
		public String getOperatorString()
		{
			return operatorString;
		}
		
		
	}
	
	private String paramName;
	private QueryParamOperator operator;
	private Object value;
	
	
	
	
	public QueryParameter(String paramName, QueryParamOperator operator, Object value) throws DAOException {
		
		if(paramName.matches("[A-Za-z0-9 ]*"))
		{
			if (value instanceof String) {
				if (!((String) value).matches("[A-Za-z0-9 ]*")) {
					throw new DAOException("Not allowed characters in query.");
				}
			}
			this.paramName = paramName;
			this.operator = operator;
			this.value = value;
		}
		else
		{
			throw new DAOException("Not allowed characters in query.");
		}
		
		
	}
	public String getParamName() {
		return paramName;
	}
	public void setParamName(String paramName) {
		this.paramName = paramName;
	}
	public QueryParamOperator getOperator() {
		return operator;
	}
	public void setOperator(QueryParamOperator operator) {
		this.operator = operator;
	}
	public Object getValue() {
		return value;
	}
	public void setValue(Object value) {
		this.value = value;
	}
	
	
	
	
}
